﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CMN.BLL;
using CMN.Common;
using CMN.Entity;
using CMN.Models.Interfaces;
namespace CMN.Models
{
    /// <summary>
    /// 图片Service
    /// </summary>
    public class Module_PhotoService: IDataService<Module_PhotoEntity>
    {
        /// <summary>
        /// 新增图片
        /// </summary>
        /// <param name="Module_PhotoEntity"></param>
        /// <returns>bool</returns>
        public string Insert(Module_PhotoEntity module_photoEntity)
        {
            module_photoEntity.DataTable_Action = DataTableAction.Insert;
            Module_Photo bll = new Module_Photo();
            if (bll.InsertUpdateDelete(module_photoEntity) > 0)
            {
                return "";
            }
            else
            {
                return "失败";
            }
        }

        /// <summary>
        /// 返回图片查询列表
        /// </summary>
        /// <param name="qp"></param>
        /// <param name="count">查询总个数</param>
        /// <returns>List</returns>
        public List<Module_PhotoEntity> List(QueryParam qp,out int count)
        {
            Module_Photo bll = new Module_Photo();
            return bll.List(qp, out count);
        }

        /// <summary>
        /// 更新图片
        /// </summary>
        /// <param name="Module_Photo"></param>
        /// <returns>bool</returns>
        public string Update(Module_PhotoEntity module_photoEntity)
        {
            module_photoEntity.DataTable_Action = DataTableAction.Update;
            Module_Photo bll = new Module_Photo();
            if (bll.InsertUpdateDelete(module_photoEntity) > 0)
            {
                return "";
            }
            else
            {
                return "失败";
            }
        }

        /// <summary>
        /// 删除图片
        /// </summary>
        /// <param name="Module_Photo"></param>
        /// <returns>bool</returns>
        public string Delete(Module_PhotoEntity module_photoEntity)
        {
            module_photoEntity.DataTable_Action = DataTableAction.Delete;
            Module_Photo bll = new Module_Photo();
            if (bll.InsertUpdateDelete(module_photoEntity) > 0)
            {
                return "";
            }
            else
            {
                return "失败";
            }
        }

        /// <summary>
        /// 批量删图片
        /// </summary>
        /// <param name="idList">删除id列表  2_8_9_45</param>
        /// <returns>bool</returns>
        public string DeleteList(string idList)
        {
            string[] list =Utils.SplitString(idList,"_");
            string strDel=Utils.ArrayToString(list,",",false);
            Module_Photo bll = new Module_Photo();
            if (bll.DelList(strDel) > 0)
            {
                return "";
            }
            else
            {
                return "失败";
            }

        }

        /// <summary>
        /// 返回单个图片
        /// </summary>
        /// <param name="id"></param>
        /// <returns>Module_PhotoEntity</returns>
        public Module_PhotoEntity Look(int id)
        {
            Module_Photo bll = new Module_Photo();
            return bll.Disp(id);
        }
    }
}
